﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using SysManage.BLL;
using ZHDJ.Core.Caching;
using ZHDJ.Data.Models.Org;
using ZHDJ.WebPage;

namespace SysManage.Module.Org
{
    public partial class PartyOrgBranchDesc : PageBase
    {
        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "PartyOrgBranchView";
            }
        }

        #endregion

        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTree();
                LoadData();
            }
        }

        private void LoadData()
        {
            
        }

        private void BindTree()
        {
            TreeControlBusiness tree = new TreeControlBusiness("BranchID", "ParentBranchID", "BranchName", true, CacheKeys.Cache_Branch_Tree);
            tree.EnableClickEvent = true;
            tree.BindTreeBranch(TreeBranch);
            if (!string.IsNullOrEmpty(BranchID))
            {
                var n = TreeBranch.FindNode(BranchID);

                TreeBranch.Nodes.Clear();
                if (n != null)
                    TreeBranch.Nodes.Add(n);
            }
            if (TreeBranch.Nodes.Count > 0)
            {
                //展开第一层
                TreeBranch.Nodes[0].Expanded = true;
            }
            Region2.IFrameUrl = "PartyOrgBranchEdit.aspx?ID=" + BranchID +"&IsBranchCenter=1";
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void TreeBranch_NodeCommand(object sender, TreeCommandEventArgs e)
        {
            hdParentBranchID.Text = e.Node.NodeID;
            Region2.IFrameUrl = "PartyOrgBranchEdit.aspx?ID=" + e.Node.NodeID+"&IsBranchCenter=1";
        }
        #endregion



    }
}
